package cn.bonoon.controllers.announcement;

import java.util.List;

import cn.bonoon.core.plugins.AnnouncementService;
import cn.bonoon.entities.interacting.AnnouncementEntity;
import cn.bonoon.kernel.annotations.Cutoff;
import cn.bonoon.kernel.annotations.Transform;
import cn.bonoon.kernel.events.DialogEvent;
import cn.bonoon.kernel.support.models.Item;
import cn.bonoon.kernel.support.services.IService;
import cn.bonoon.kernel.web.EmbedType;
import cn.bonoon.kernel.web.annotations.form.FormDetail;
import cn.bonoon.kernel.web.annotations.form.InsertCell;
import cn.bonoon.kernel.web.annotations.form.PropertyDetail;
import cn.bonoon.kernel.web.handlers.DialogFormInitializer;
import cn.bonoon.kernel.web.models.DialogModel;

@Transform
@FormDetail(value = 2, width = 250)
@InsertCell(name = "发布到", value = "/sys/release-module-readonly.vm", colspan = 1, type = EmbedType.PARSE)
public class AnnouncementDetail implements AnnouncementDefine, DialogFormInitializer<AnnouncementEntity> {

	@PropertyDetail(0)
	private String platform;
	@PropertyDetail(1)
	private String type;

	@PropertyDetail(10)
	private String topest;
	@PropertyDetail(11)
	private String topTo;
	
	@PropertyDetail(20)
	private String creatorName;
	@PropertyDetail(21)
	private String createAt;
	
	@PropertyDetail(value = 40, colspan = 1, height = 250)
	@Cutoff(-1)
	private String content;

	@Override
	public Object init(IService<AnnouncementEntity> service, DialogModel model,
			DialogEvent event, Long id, Object form) throws Exception {
		AnnouncementService announcementService = (AnnouncementService)service;
		List<Item> modules = announcementService.releasePlaform(event, id);
		model.addObject("modules", modules);
		return form;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCreatorName() {
		return creatorName;
	}

	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}

	public String getCreateAt() {
		return createAt;
	}

	public void setCreateAt(String createAt) {
		this.createAt = createAt;
	}

	public String getPlatform() {
		return platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}

	public String getTopest() {
		return topest;
	}

	public void setTopest(String topest) {
		this.topest = topest;
	}

	public String getTopTo() {
		return topTo;
	}

	public void setTopTo(String topTo) {
		this.topTo = topTo;
	}
}
